﻿using Devonline.AspNetCore;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Logging;

namespace Devonline.Identity;

/// <summary>
/// 认证类数据处理服务接口
/// 字符串作为主键的默认实现接口
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
/// <typeparam name="TKey">主键类型</typeparam>
public interface IDataService<TEntitySet, TKey> : IDataService<IdentityDbContext, TEntitySet, TKey> where TEntitySet : class, IEntitySet<TKey> where TKey : IConvertible { }

/// <summary>
/// 认证类数据处理服务接口
/// 字符串作为主键的默认实现接口
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
public interface IDataService<TEntitySet> : IDataService<TEntitySet, string> where TEntitySet : class, IEntitySet { }

/// <summary>
/// 认证类数据处理服务
/// 字符串作为键的默认实现
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
/// <typeparam name="TKey">主键类型</typeparam>
public class DataService<TEntitySet, TKey> : DataService<IdentityDbContext, TEntitySet, TKey>, IDataService<TEntitySet, TKey> where TEntitySet : class, IEntitySet<TKey> where TKey : IConvertible
{
    public DataService(
        IdentityDbContext context,
        ILogger<DataService<TEntitySet, TKey>> logger,
        IDistributedCache cache,
        IHttpContextAccessor httpContextAccessor,
        AppSetting appSetting
        ) : base(context, logger, cache, httpContextAccessor, appSetting) { }
}

/// <summary>
/// 认证类数据处理服务
/// 字符串作为键的默认实现
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
public class DataService<TEntitySet> : DataService<TEntitySet, string>, IDataService<TEntitySet> where TEntitySet : class, IEntitySet
{
    public DataService(
        IdentityDbContext context,
        ILogger<DataService<TEntitySet>> logger,
        IDistributedCache cache,
        IHttpContextAccessor httpContextAccessor,
        AppSetting appSetting
        ) : base(context, logger, cache, httpContextAccessor, appSetting) { }
}